/*
  File: CourseEntity.cs
  Author: rcrxy
  CreateTime: 2025/06/26 18:37

  Description:
*/

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using NUlid;

namespace StudentVideo.Data.Entities;

/// <summary>
/// 课程
/// </summary>
[Table("course")]
[Index(nameof(Code), IsUnique = true)]
public class CourseEntity: BaseEntity {

   [Key]
   [MaxLength(50)]
   public new string Id { get; set; } = Ulid.NewUlid().ToString();

   /// <summary>
   /// 名称
   /// </summary>
   [Required]
   [MaxLength(50)]
   public required string Name { get; set; }

   /// <summary>
   /// 编码
   /// </summary>
   [Required]
   [MaxLength(50)]
   public required string Code { get; set; }

   /// <summary>
   /// 启用状态
   /// </summary>
   public bool Enable { get; set; } = true;

   [InverseProperty(nameof(VideoEntity.Course))]
   public ICollection<VideoEntity>? Videos { get; set; }

   [InverseProperty(nameof(MajorCourseMapEntity.Course))]
   public ICollection<MajorCourseMapEntity>? MajorCourseMaps { get; set; }
}
